package com.hushao.aimi.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.time.LocalDateTime;

/**
 * @description: 订单信息
 * @author: 胡少
 * @create: 2018-06-03 17:10
 **/
@ApiModel("订单信息")
@Data
@Entity
public class AimiOrder implements Serializable {

    @Id
    @GenericGenerator(name = "uuid",strategy = "uuid")
    @GeneratedValue(generator = "uuid")
    @Column(length = 32)
    private String id;

    @ApiModelProperty("订单号")
    @Column(nullable = false,unique = true)
    private Long orderNo;

    @ApiModelProperty("用户id")
    @Column(length = 32,nullable = false)
    private String userId;

    @ApiModelProperty("地址id")
    @Column(length = 32,nullable = false)
    private String addressId;

    @ApiModelProperty("实际付款金额")
    @Column(nullable = false)
    private BigDecimal payment;

    @ApiModelProperty("支付类型:1-在线支付")
    @Column(nullable = false)
    private byte paymentType;

    @ApiModelProperty("运费")
    private Integer freight;

    @ApiModelProperty("订单状态：0-取消；1-未付款[默认]；2-已付款；3-已发货；4-交易成功；5-交易关闭")
    @Column(nullable = false)
    private Integer status=1;

    @ApiModelProperty("支付时间")
    private LocalDateTime payTime;

    @ApiModelProperty("发货时间")
    private LocalDateTime sendTime;

    @ApiModelProperty("交易成功时间")
    private LocalDateTime endTime;

    @ApiModelProperty("交易关闭时间")
    private LocalDateTime closeTime;

    @ApiModelProperty("创建时间")
    @CreationTimestamp
    private Timestamp createTime;

    @ApiModelProperty("更新时间")
    @UpdateTimestamp
    private Timestamp updateTime;

    @ApiModelProperty("备注")
    @Column(length = 512)
    private String comment;

    public AimiOrder(Long orderNo, String userId, String addressId, BigDecimal payment, byte paymentType, Integer freight, Integer status, LocalDateTime payTime, LocalDateTime sendTime, LocalDateTime endTime, LocalDateTime closeTime, Timestamp createTime, Timestamp updateTime, String comment) {
        this.orderNo = orderNo;
        this.userId = userId;
        this.addressId = addressId;
        this.payment = payment;
        this.paymentType = paymentType;
        this.freight = freight;
        this.status = status;
        this.payTime = payTime;
        this.sendTime = sendTime;
        this.endTime = endTime;
        this.closeTime = closeTime;
        this.createTime = createTime;
        this.updateTime = updateTime;
        this.comment = comment;
    }


}
